package com.wufun.overseas.adapters;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wufun.overseas.R;
import com.wufun.overseas.main.activity.SetWebViewActivity;
import com.wufun.overseas.models.bean.TitlePopoWinBean;

import java.util.List;

/**
 * Created by yangg on 2017/12/18.
 */

public class TitlePopoAdapter extends BaseAdapter {
    Context mContext;
    List<TitlePopoWinBean.DataBean.ListBean> list;

    public TitlePopoAdapter(Context mContext, List<TitlePopoWinBean.DataBean.ListBean> list) {
        this.list = list;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.titile_popo_item, null);
            viewHolder.ll_item = (LinearLayout) convertView.findViewById(R.id.ll_popo_item);
            viewHolder.tv_name = (TextView) convertView.findViewById(R.id.tv_popo_name);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.tv_name.setText(list.get(position).getName());

       viewHolder.ll_item.setBackgroundResource(R.drawable.recom_title_popo);


        return convertView;
    }

    class ViewHolder {
        LinearLayout ll_item;
        TextView tv_name;
    }
}
